package Demo;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictServer extends UdpEchoServer {
    private Map<String, String> dict = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("bird", "小鸟");
        dict.put("fish", "小鱼");
        dict.put("elephant", "大象");
        dict.put("lion", "狮子");
        dict.put("tiger", "老虎");
        dict.put("monkey", "猴子");
        dict.put("chicken", "鸡");
        dict.put("dog", "狗");
    }
    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "抱歉,没有找到相应翻译");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(8080);
        server.start();
    }

}



